from django.db import models

# Create your models here.
class Students(models.Model):

    name=models.CharField(max_length=20,verbose_name='姓名',db_comment='存储姓名',db_column='stu_name')
    age=models.IntegerField(help_text='大于18',verbose_name='年龄')
    SEX_CHOICES = (1, '男'), (2, '女')
    sex=models.IntegerField(choices=SEX_CHOICES,default=1,verbose_name='性别')
    class Meta:
        # verbose_name指定在admin管理界面中显示中文；
        # verbose_name表示单数形式的显示，verbose_name_plural表示复数形式的显示；中文的单数和复数一般不作区别。
        verbose_name_plural = verbose_name = '学生表'
    def __str__(self):
        return  f'{self.name}({self.pk})'

class Place(models.Model):
    name=models.CharField(max_length=50,verbose_name='地名')
    address=models.CharField(max_length=80,verbose_name='门牌')
    def __str__(self):
        return f'{self.name}--{self.address}'
    class Meta:
        verbose_name_plural=verbose_name='地址'
class Restaurant(models.Model):
    place=models.OneToOneField(Place,on_delete=models.CASCADE,
                               primary_key=True,
                               verbose_name='地址')
    name=models.CharField(max_length=50,verbose_name='名称')
    serves_hot_dogs=models.BooleanField(default=False,verbose_name='经营热狗')
    serves_pizza = models.BooleanField(default=False, verbose_name='经营披萨')
    start_time=models.DateField(verbose_name='开创时间',null=True)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = verbose_name = '餐馆'

class Waiter(models.Model):
    restaurant = models.ForeignKey(Restaurant, on_delete=models.CASCADE, verbose_name='餐馆')
    name = models.CharField(max_length=50, verbose_name='姓名')

    def __str__(self):
        return self.name

    class Meta:

        verbose_name_plural = verbose_name = '服务员'
class SchoolClass(models.Model):
    name = models.CharField(max_length=20, verbose_name='班级名')

    class Meta:

        verbose_name_plural = verbose_name = '班级'

    def __str__(self):
        return self.name

class Teacher(models.Model):
    name = models.CharField(max_length=10, verbose_name='姓名')
    school_class = models.ManyToManyField(SchoolClass, verbose_name='班级')

    class Meta:

        verbose_name_plural = verbose_name = '老师'

    def __str__(self):
        return self.name


